package top.lakakala.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import top.lakakala.entity.Bulletin;
import top.lakakala.entity.WorkInfo;
import top.lakakala.service.BulletinService;
import top.lakakala.service.WorkInfoService;

import java.util.List;
import java.util.Map;

/**
 * Created by k3312 on 2017/8/3.
 */
@Controller
@RequestMapping("index")
public class IndexController {
    @Autowired
    private WorkInfoService workInfoService;
    @Autowired
    private BulletinService bulletinService;

    @RequestMapping()
    public String index(ModelMap modelMap) {
        Map<String, List<WorkInfo>> workInfoListMap = workInfoService.indexWorkInfoList();
        List<WorkInfo> leftWorkInfoList = workInfoListMap.get(workInfoService.LEFT_WORK_INFO_INFO);
        List<WorkInfo> rightWorkInfoList = workInfoListMap.get(workInfoService.RIGHT_WORK_INFO_INFO);

        List<Bulletin> bulletinList = bulletinService.indexBulletionList();

        modelMap.addAttribute("leftWorkInfoList", leftWorkInfoList);
        modelMap.addAttribute("rightWorkInfoList", rightWorkInfoList);

        modelMap.addAttribute("bulletinList", bulletinList);
        return "index";
    }
}
